<template>
    <view :style="themeColor">
        <view class="page">
            <view class="flex align-stretch benben-position-layout flex searchFor_flex_0" :style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }">
                <view class='flex align-center justify-between flex-sub searchFor_fd0_0'>
                    <view class='flex align-center' @tap.stop="handleJumpDiy" data-type="back" data-url="1">
                        <text class='fu-iconfont2  searchFor_fd0_0_c0_c0'>&#xE794;</text>
                    </view>
                    <view class='flex align-center flex-sub searchFor_fd0_0_c1'>
                        <text class='fu-iconfont2  searchFor_fd0_0_c1_c0'>&#xe77e;</text>
                        <input class='flex-sub searchFor_fd0_0_c1_c1' type="text" :placeholder="$t('请输入关键字')" confirm-type="done" :maxlength="-1" placeholder-style="color:rgba(153, 153, 153, 1);font-size:28rpx" @confirm="addSearchFunc()" v-model="keywords" />
                    </view>
                    <view class='flex flex-wrap align-center' @tap.stop="handleJumpDiy" data-type="back" data-url="1">
                        <text class='searchFor_fd0_0_c2_c0'>{{$t('取消')}}</text>
                    </view>
                </view>

            </view>
            <view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
            <!---搜索记录flex布局开始-->
            <view class="flex flex-direction flex-wrap align-stretch benben-flex-layout searchFor_flex_1">
                <view class='flex flex-wrap align-center searchFor_fd1_0'>
                    <text class='searchFor_fd1_0_c0'>{{$t('历史搜索')}}</text>
                    <image class='searchFor_fd1_0_c1' mode="aspectFit" :src='STATIC_URL+"33.png"' @tap.stop="popupShow1699434477887=true"></image>
                </view>
                <view class='flex flex-wrap align-center searchFor_fd1_1' v-if=" appSearchHistory.length!=0">
                    <template v-for='(item,key0) in appSearchHistory'>
                        <view class='flex flex-wrap align-center searchFor_fd1_1_c0' @tap.stop="handleJumpDiy" data-type="navigateTo" :data-url="`/pages/shouye/searchResult/searchResult?keyworld=${item.name}`" :key='key0'>
                            <text class='searchFor_fd1_1_c0_c0'>{{item.name}}</text>
                        </view>
                    </template>

                </view>
                <text class='searchFor_fd1_2' v-if=" appSearchHistory.length==0">{{$t('暂无历史记录')}}</text>
            </view>

            <!---搜索记录flex布局结束-->
            <benben-popup v-model="popupShow1699434477887" :mask="true" :mask-close-able="false" mode='center' :z-index='999'>
                <!---退出登录flex布局开始-->
                <view class="flex flex-direction flex-wrap align-center searchFor_flex_2" @tap.stop="popupShow1650940432200=true">
                    <text class='searchFor_fd2_0'>{{$t('提示')}}</text>
                    <text class='searchFor_fd2_1'>{{$t('确定要删除搜索记录？')}}</text>
                    <view class='flex align-center searchFor_fd2_2'>
                        <button class='searchFor_fd2_2_c0' @tap.stop="popupShow1699434477887=false" open-type="contact">{{$t('取消')}}</button>
                        <button class='searchFor_fd2_2_c1' @tap.stop="emptySearchHistoryFunc()" open-type="contact">{{$t('确定')}}</button>
                    </view>
                </view>

                <!---退出登录flex布局结束-->

            </benben-popup>


        </view>
    </view>
</template>
<script>
    import {
        validate
    } from '@/common/utils/validate.js'
    export default {
        components: {},


        data() {
            return {
                "popupShow1699434477887": false,
                "removeIndex": -1,
                "keywords": ""
            };
        },
        computed: {
            themeColor() {
                return this.$store.getters.themeColor
            },
            appSearchHistory() { // 搜索历史
                return this.$store.state.appSearchHistory
            }
        },
        watch: {},
        onLoad(options) {

        },
        onUnload() {

        },
        onReady() {

        },
        onShow() {

        },
        onHide() {

        },
        onResize() {

        },
        onPullDownRefresh() {

        },
        onReachBottom(e) {

        },
        onPageScroll(e) {

        },
        methods: {
            //清空搜索记录
            emptySearchHistoryFunc() {
                this.$store.commit('appSearchHistoryClean', '')
                this.popupShow1699434477887 = false;
            },
            //长按事件
            handleLongpressFunc(index) {
                this.removeIndex = index;
            },
            //删除搜索历史
            deleteSearchHistoryFunc(name) {
                this.$store.commit('appSearchHistoryDel', {
                    "name": name
                })
            },
            //添加搜索记录
            async addSearchFunc() {
                //请求方法
                //数据验证

                let data6552ebab65a75 = await this.$api.post(global.apiUrls.post6552ebab65a75, {
                    name: this.keywords
                });

                if (data6552ebab65a75.data.code != 1) {
                    this.$message.info(data6552ebab65a75.data.msg);
                    return
                }



                this.$store.commit('appSearchHistoryAdd', {
                    "name": this.keywords
                })
                this.$urouter.navigateTo(`/pages/shouye/searchResult/searchResult?keyworld=${this.keywords}&type=`);
            }
        }
    };
</script>
<style lang="scss" scoped>
    .page {
        width: 100vw;
        overflow-x: hidden;
        min-height: calc(100vh - var(--window-bottom));
        background: rgba(255, 255, 255, 1);
        background-size: 100% auto;
    }

    .searchFor_flex_0 {
        background: #fff;
        width: 750rpx;
        height: 88rpx;
        overflow: hidden;
        z-index: 10;
        top: 0rpx;
        background-size: 100% auto !important;
    }

    .searchFor_fd0_0_c2_c0 {
        color: #333333;
        font-size: 28rpx;
        font-weight: 500;
        line-height: 40rpx;
        margin: 0rpx 0rpx 0rpx 6rpx;
    }

    .searchFor_fd0_0_c1_c1 {
        font-size: 28rpx;
        font-weight: 400;
        color: #333;
    }

    .searchFor_fd0_0_c1_c0 {
        font-size: 31rpx;
        color: rgba(153, 153, 153, 1);
        margin: 0rpx 13rpx 0rpx 0rpx;
    }

    .searchFor_fd0_0_c1 {
        background: #F9F9F9;
        height: 64rpx;
        border-radius: 34rpx 34rpx 34rpx 34rpx;
        padding: 0rpx 35rpx 0rpx 35rpx;
        margin: 0rpx 32rpx 0rpx 40rpx;
    }

    .searchFor_fd0_0_c0_c0 {
        font-size: 36rpx;
        font-weight: 500;
        color: #333;
    }

    .searchFor_fd0_0 {
        padding: 0rpx 24rpx 0rpx 24rpx;
        line-height: 88rpx;
    }

    .searchFor_flex_1 {
        padding: 0rpx 0rpx 0rpx 0rpx;
    }

    .searchFor_fd1_2 {
        font-size: 24rpx;
        font-weight: 400;
        color: #666666;
        margin: 0rpx 32rpx 32rpx 32rpx;
    }

    .searchFor_fd1_1_c0_c0 {
        font-size: 24rpx;
        font-weight: 400;
        color: rgba(51, 51, 51, 1);
    }

    .searchFor_fd1_1_c0 {
        background: rgba(248, 248, 248, 1);
        border-radius: 8rpx;
        background-size: 100% auto !important;
        padding: 0rpx 24rpx 0rpx 24rpx;
        line-height: 56rpx;
        margin: 0rpx 12rpx 24rpx 12rpx;
    }

    .searchFor_fd1_1 {
        padding: 0rpx 0rpx 0rpx 12rpx;
    }

    .searchFor_fd1_0_c1 {
        width: 40rpx;
        height: 40rpx;
        border-radius: 0rpx 0rpx 0rpx 0rpx;
        margin: 0rpx 0rpx 0rpx auto;
    }

    .searchFor_fd1_0_c0 {
        font-size: 32rpx;
        font-weight: 500;
        color: #333333;
        line-height: 42rpx;
    }

    .searchFor_fd1_0 {
        padding: 32rpx 0rpx 24rpx 0rpx;
        margin: 0rpx 32rpx 0rpx 32rpx;
    }

    .searchFor_flex_2 {
        background: #fff;
        width: 540rpx;
        border-radius: 16rpx 16rpx 16rpx 16rpx;
        padding: 0rpx 0rpx 41rpx 0rpx;
    }

    .searchFor_fd2_2_c1 {
        background: rgba(1, 129, 255, 1);
        border-radius: 36rpx;
        font-size: 28rpx;
        color: rgba(255, 255, 255, 1);
        width: 176rpx;
        height: 72rpx;
    }

    .searchFor_fd2_2_c0 {
        background: rgba(248, 248, 248, 1);
        border-radius: 36rpx;
        font-size: 28rpx;
        color: rgba(51, 51, 51, 1);
        width: 176rpx;
        height: 72rpx;
        margin: 0rpx 20rpx 0rpx 0rpx;
    }

    .searchFor_fd2_2 {
        margin: 37rpx 0rpx 0rpx 0rpx;
    }

    .searchFor_fd2_1 {
        line-height: 44rpx;
        font-size: 32rpx;
        font-weight: 500;
        color: #333333;
    }

    .searchFor_fd2_0 {
        font-size: 36rpx;
        font-weight: 800;
        line-height: 44rpx;
        color: #333333;
        margin: 40rpx 0rpx 40rpx 0rpx;
    }
</style>